home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscMatrix.h -- a class to implement variable-sized matrices
- // Written by Mike Ferris Copyright (c) 1994 by Mike Ferris.
- // Modified from original MOKit "MOMatrix" class by Don Yacktman.
- // Version 1.0. All rights reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- // MiscMatrix is a subclass of Matrix that allows independantly sizable
- // rows and columns. Each row can have a different height and each column
- // can have a different width.
-
- /*
- Bugs: In the private methods for altering row/column locations when you
- insert a row/column before the last position, the last position
- would not get properly incremented.
-
- If you have 0 rows and 0 cols in the matrix, when you go to insert a
- row it'll insert a column for you, similarly if you insert a col it'll
- insert a row, MiscMatrix wasn't taking that into account.
-
- Modified the _loopHit to work a little better by calling
- getRow:andCol:forPoint:wantsGuess:TRUE, which will insure that
- you get the proper number of selected cells if you drag out of
- the window
-
- I think it was SQ, but SQ postulated that addRow is really a front
- for insertRowAt: and to prove his point he left in some code that
- would log a message if it didn't work the way he posulated. It
- does work the way SQ postulated (at least from my experience) but it
- is still possible for his message to print. The error could be
- printed if these steps happen: init a matrix via initFrame:, now
- the matrix will have 0 cells, but its numRows == numCols == 1. If
- you then go and call addRow, its numRows == numCols == 1 in the
- begining and end, which logs an error. I just took out the
- methods for addRow/addCol as they weren't really doing anything.
- */
-
- /*
- Posible Bug: (Carl E. Lindberg <lindberg@CS.COLGATE.EDU>)
- Playing with my very simple example, (just using Buttons as
- the cells), I was very occasionally able to get a one-pixel
- error (one pixel of the last row/column buttons was clipped),
- but otherwise I think it worked exactly as the docs to Matrix
- say it should. Usually, it worked just fine, and calls to
- -setAutosizeCells: would line that one pixel back up.
-
- If this one-pixel thing may be a problem, use the
- #ifdef FUDGE sections in the two methods. Basically, they are
- just making the resizing calculations size to one pixel smaller.
- This means that the occasional error will now be perfectly on
- the edge, but usually you have an extra pixel's space around
- two edges of the MiscMatrix. Since the regular Matrix often
- seems to have more than one pixel, I doubt this is a problem.
- */
-
- /* Note: I (Georg Tuparev <Tuparev@EMBL-Heidelberg.de> am writing
- completely new version for the MiscKit 2.x. Please send me suggestions
- and wishes. I'm going to combine the functionality of MiscMatrix and
- MiscSelectionMatrix as well as The NiftyMatrix (NeXT Examples) and build
- entire hierarchy of classes, including simple one column browser,
- IndentBrowser (similar to the new IB class view) and different palettes.
- */
-
- #import <appkit/appkit.h>
-
- typedef struct _MiscColumnSize_ {
- NXCoord x;
- NXCoord width;
- } MiscColumnSize;
- #define MISC_COLUMNSIZE_DESC "{ff}"
-
- typedef struct _MiscRowSize_ {
- NXCoord y;
- NXCoord height;
- } MiscRowSize;
- #define MISC_ROWSIZE_DESC "{ff}"
-
- @interface MiscMatrix : Matrix
- {
- Storage *columnSizes, *rowSizes;
-
- }
-
- + initialize;
-
- - initFrame:(const NXRect *)frm mode:(int)aMode prototype:cellId
- numRows:(int)rowsHigh numCols:(int)colsWide;
- - initFrame:(const NXRect *)frm mode:(int)aMode cellClass:factoryId
- numRows:(int)rowsHigh numCols:(int)colsWide;
-
- - copyFromZone:(NXZone *)zone;
-
- - free;
-
- - setWidth:(NXCoord)newWidth ofCol:(int)col;
- - setHeight:(NXCoord)newHeight ofRow:(int)row;
- - (float)widthOfCol:(int)aCol;
- - (float)heightOfRow:(int)aRow;
-
- - (float)totalWidthPerRow;
-
- - setCellSize:(const NXSize *)aSize;
- - sizeToCells;
- - sizeToFit;
- - sizeRowsToFitCells;
- - sizeTo:(NXCoord)width :(NXCoord)height;
- - setAutosizeCells:(BOOL)flag;
-
- - renewRows:(int)newRows cols:(int)newCols;
-
- - insertColAt:(int)col;
- - insertRowAt:(int)row;
- - removeColAt:(int)col andFree:(BOOL)flag;
- - removeRowAt:(int)row andFree:(BOOL)flag;
-
- - drawSelf:(const NXRect *)rects :(int)rectCount;
-
- - getCellFrame:(NXRect *)theRect at:(int)row :(int)col;
- - getRow:(int *)row andCol:(int *)col forPoint:(const NXPoint *)aPoint;
- - getRow:(int *)row andCol:(int *)col forPoint:(const NXPoint *)aPoint
- wantsGuess:(BOOL)shouldGuess;
-
- - setIntercell:(const NXSize *)aSize;
-
- - (int)numCols;
- - (int)numRows;
-
- - write:(NXTypedStream *)typedStream;
- - read:(NXTypedStream *)typedStream;
-
- @end
-
- @interface Storage(MiscLastElementCategory)
-
- - (void *)lastElement;
-
- @end